<!--{template header,admin}-->
<div>
<div style="width:100%; height:15px;color:#000;margin:0px 0px 10px;">
    <div >
    <ol class="breadcrumb">
  <li><a href="{url admin_main/stat}">后台首页</a></li>
  <li><a href="{url admin_myplugin/clist}">插件列表</a></li>
  <li class="active">{$navtitle}</li>
</ol>

</div>
<div style="padding:8px;">

<div class="row" style="margin-bottom:8px;">
<div class="row">
<div class="col-sm-12">

<div class="alert alert-success">
<strong>{$leveltext}</strong>
<p>更新包下载和备份目录:{$dirlocation}</p>
</div>

</div>

</div>

{if $msg!=''}
<div class="row">
<div class="col-sm-12">

<div class="alert alert-warning">
{$msg}
</div>

</div>

</div>
{/if}
<table class="table">

  <thead>
    <tr>
      <th>更新简介</th>
     
      <th>发布日期</th>
      <th width="120px">适合版本</th>
      <th>可下载</th>
      <th>是否更新</th>
      <th>操作</th>
    </tr> 
  </thead>
  <tbody>
  {loop $filelist $file}
    <tr>
      <td>{$file['name']}
      <span class="label label-primary">V{$file['version']}</span>
      </td>
   
      <td>{$file['format_time']}</td>
       <td width="120px" >{$file['leveluser']}</td>
       <td>  
        {if $file['status']==1}
            <span class="label label-success">可下载</span>
       {else}
          <span class="label label-danger">不可下载</span>
        {/if}
    </td>
       <td>  
        {if $file['downlog']==1}
            <span class="label label-success showupdatetime" data-toggle="tooltip" data-placement="left" title="最后更新时间：{$file['downtime']}">已更新</span>
       {else}
          <span class="label label-danger">未更新</span>
        {/if}
    </td>
      <td>

      <button  data-scroll-inside="true"   class="btndo btn btn-info btn-sm" data-moveable="true" data-toggle="modal"  data-target="#myModal{$file['id']}">查看更新内容</button>
                      <div class="modal fade" id="myModal{$file['id']}">
  <div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
        <h4 class="modal-title">{$file['name']}-V{$file['version']}(安装时间:{$file['format_time']})</h4>
      </div>
         <div class="modal-body"  style="max-height: 600px;overflow:scroll;">
  {$file['content']}
 </div>
    </div>
  </div>
</div>
 {if $file['downlog']==1}
         <button data-id="{$file['id']}" onclick="downfile({$file['id']})" class="btndo btn btn-sm">重新下载并更新</button>
         <button data-id="{$file['id']}" onclick="backupsource({$file['id']})" class="btndo btn btn-primary btn-sm">恢复</button>
       {else}
      
          <button   data-id="{$file['id']}"  onclick="downfile({$file['id']})" class="btndo btn btn-primary btn-sm">下载并更新</button>
        {/if}
        
      </td>
      
    </tr>
{/loop}
  </tbody>
</table>
<div class="pages">{$departstr}</div>
</div>
<script>
//你需要手动初始化工具提示
$('[data-toggle="tooltip"]').tooltip();
function downfile(_fileid){
	$(".btndo").attr("disabled",true);
	var _url="{url admin_onlineupdate/updatefile}";
	var _data={"fileid":_fileid};
	function success(result){
      console.log(result);
      $(".btndo").removeAttr("disabled");
      $(".btndo").attr("disabled",false);
      if(result.code==200){
window.location.reload();
      }
      alert(result.msg);
	}
	ajaxpost(_url,_data,success);
}
function backupsource(_fileid){
	$(".btndo").attr("disabled",true);
	var _url="{url admin_onlineupdate/backupsource}";
	var _data={"fileid":_fileid};
	function success(result){
      console.log(result);
      $(".btndo").removeAttr("disabled");
      $(".btndo").attr("disabled",false);
      alert(result.msg);
	}
	ajaxpost(_url,_data,success);
}
</script>
<!--{template footer,admin}-->
</div>